﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Mvc;

namespace EasyUIDemo.MVC.Controllers
{
    public class prospectController : Controller
    {
        //
        // GET: /prospect/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="where"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public ActionResult prospects(string where,int id, int pageindex = 1)
        {
            int pagesize = 5;
            string strwhere = "";
            if (where != null)
            {
                strwhere += " and ";
            }

            using (HttpClient client = new HttpClient())
            {
                string strurl = "http://localhost:63805/apis/prospect/listget?pageindex=" + pageindex + "&pagesize=" + pagesize + "&wherestr=" + strwhere+"&id="+id;
                var result = client.GetAsync(strurl).Result;
                if (result.IsSuccessStatusCode)
                {
                    var BasicModel = result.Content.ReadAsStringAsync().Result;
                    var list = Newtonsoft.Json.JsonConvert.DeserializeObject<pagelist<Basic_Info>>(BasicModel);
                    return View(list.getlist);
                }
                else
                {
                    return Content("<script>alert('请求出错')</script>");
                }
            }
            
        }

    }
}
